import {ref} from "vue";
import {defineStore} from "pinia";
// /*
// 第一个参数是store的id，必须唯一
// 第二个参数: 一个函数，返回一个对象，对象中的属性，
// pinia会自动的保存起来，pinia会自动的保存在浏览器的sessionStorage中
//  */
export const useTokenStore = defineStore('token', () => {
        const token = ref('')
        const setToken = (newToken) => {
            token.value = newToken
        }
        const clearToken = () => {
            token.value = ''
        }
        return {token, setToken, clearToken}
    },
    {
        presist: true
    }
);
export const supplierTokenStore = defineStore('supplierToken', () => {
        const supplierToken = ref('')
        const setSupplierToken = (newSupplierToken) => {
            supplierToken.value = newSupplierToken
        }
        const clearSupplierToken = () => {
            supplierToken.value = ''
        }
        return {supplierToken, setSupplierToken, clearSupplierToken}
    },
    {presist: true}
);
export const headImgStore = defineStore('headImg', () => {
        const headImg = ref('')
        const setHeadImg = (newHeadImg) => {
            headImg.value = newHeadImg
        }
        const clearHeadImg = () => {
            headImg.value = ''
        }
        return {headImg, setHeadImg, clearHeadImg}
    },
    {presist: true});
export const isLoginStore = defineStore('isLogin', () => {
        const isLogin = ref(false)
        const resetLogin = (newLogin) => {
            isLogin.value = newLogin
        }
        return {isLogin, resetLogin}
    },
    {presist: true}
);